﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Model
{
    /// <summary>
    /// 验证策略
    /// </summary>
    public class ValidationStrategy : IValidationStrategy
    {
        /// <summary>
        /// 验证是否是手机号码
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public bool ValidatePhone(string phone)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(phone, @"^1[3578]\d{9}$");
        }

        /// <summary>
        /// 验证密码
        /// 长度在6~18之间,不能含有空格和汉字
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool ValidatePassword(string password)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(password, @"^[^\s\u4e00-\u9fa5]{6,18}$");
        }


        public bool ValidateNickName(string nickname)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(nickname, @"^[\u4e00-\u9fa5_a-zA-Z0-9]{1,12}");
        }
    }
}
